package com.homni.iomix_xair.activity;


import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.SeekBar;
import android.widget.TextView;

import com.homni.iomix_xair.R;


public class PanDialogFragment extends DialogFragment {

    private static final String TAG = "TAG";

    private View view;
    private TextView mPanTxt;
    private SeekBar mPanSeekbar;
    private int mTag;


    public interface PanDialogCallback {
        public void onProgressChangedComplete(int tag, int value);
    }

    public PanDialogFragment() {
        // Required empty public constructor
    }

    public static PanDialogFragment newInstance(int tag) {
        PanDialogFragment fragment = new PanDialogFragment();
        Bundle args = new Bundle();
        args.putInt(TAG, tag);
        fragment.setArguments(args);
        return fragment;
    }


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (getArguments() != null) {
            mTag = getArguments().getInt(TAG);
        }
    }

    public void onResume() {
        super.onResume();
        getDialog().getWindow().setLayout(1920, 250);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);

        view = inflater.inflate(R.layout.fragment_pan_dialog, container, false);
        initView();
        initListener();
        return view;
    }

    private void initView() {
        mPanTxt = (TextView) view.findViewById(R.id.tv_pan);
        mPanSeekbar = (SeekBar) view.findViewById(R.id.seekbar_pan);

    }

    private void initListener() {
        mPanSeekbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
            @Override
            public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
                PanDialogCallback mCallback = (PanDialogCallback)getActivity();
                mCallback.onProgressChangedComplete(mTag,i);

            }

            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {

            }

            @Override
            public void onStopTrackingTouch(SeekBar seekBar) {

            }
        });
    }

    private void initData() {

    }

}
